package com.ychen.core;

import com.ychen.core.config.ApplicationConfig;
import com.ychen.core.server.JettyServer;
import com.ychen.core.service.HelloService;
import org.apache.dubbo.container.Main;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author chenyuliao
 * @version 1.0
 * @description
 * @date 2020/11/26 22:13
 */
public class ApplicationDemoCore {

    public static void main(String[] args) {
        JettyServer.run();

//        Main.main(args);
//        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ApplicationConfig.class);
//        HelloService helloService = applicationContext.getBean(HelloService.class);
//        helloService.sayHello();

//        // 读取mybatis-config.xml 文件
//        InputStream inputStream = null;
//        try {
//            inputStream = Resources.getResourceAsStream("mybatis-config.xml");
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        // 初始化mybatis
//        // 创建SqlSessionFactory 类的实例
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
//        // 创建Session 实例
//        SqlSession session = sqlSessionFactory.openSession();
//        CourseMapper mapper = session.getMapper(CourseMapper.class);
//        List<CourseEntity> list = mapper.query();
//        for (CourseEntity courseEntity : list) {
//            System.out.println(courseEntity.toString());
//        }
//        无法执行
//        List<Object> objects = session.selectList("select * from course_1");

//        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
//        context.start();
//        DemoService demoService = (DemoService) context.getBean("demoService");
//        String hello = demoService.sayHello("world");
//        System.out.println(hello);
//        try {
//            System.in.read(); // 按任意键退出
//        } catch (IOException e) {
//            e.printStackTrace();
//        }


    }
}
